﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>Ecology</title>
<!-- Stylesheets -->
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- Responsive -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link href="css/responsive.css" rel="stylesheet">
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<!--[if lt IE 9]><script src="js/respond.js"></script><![endif]-->
    <style>
        th{
            background-color: #bcbcbc;
            border: 1px #bcbcbc solid;
            text-align: center;
        }
        tr {
            padding: 0;
            margin: 0;
            border: 0;
        }
        td {
            padding: 0;
            margin: 0;
            width: 6%;
            font-size: 13px;
            text-align: center;
            border: 1px #8d8d8d solid;
        }
    </style>
    <script>
        function deleteMedicine(id, pageNum) {
            if(confirm(`确定删除这条数据?`)) {
                $.ajax({
                    type: "GET",
                    url: `/deleteMedicine?id=${id}&pageNum=${pageNum}`,
                    success: function (data) {
                        window.location.reload();
                    }
                });
            }
        };
    </script>
</head>

<body>
<label class="page-wrapper">
    <div class="preloader"></div>
    <header class="main-header">
    	<div class="top-bar">
        	<div class="top-container">
                 <div class="info-outer">
                    <ul class="info-box clearfix">
                        <li><a href="/user/logout">退出登录</a></li>
                        <li><a href="userCenterPage" th:text="${res.user.username}"></a></li>
                    </ul>
                 </div>
            </div>
        </div>
        <div class="header-upper">
            <div class="auto-container clearfix">
                <div class="logo" style="width: 20%">
                    <a href="#"><img src="images/logo-1.png" alt="Ecology"></a>
                 </div>
                <div class="nav-outer clearfix">
                    <nav class="main-menu">
                        <div class="navbar-header">
                            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                            </button>
                        </div>
                        <div class="navbar-collapse collapse clearfix">
                            <ul class="navigation">
                                <li><a href="areaPage">管理土地</a></li>
                                <li><a href="cropTypePage">管理农作物种类</a></li>
                                <li><a href="uploadCropsPage">管理农作物</a></li>
                                <li><a href="seePage">实时监控</a></li>
                                <li><a href="#" style="color: #0F9E5E">植物农药管理</a></li>
                                <li><a href="messagePage">通知公告</a></li>
                                <li><a href="searchAudit">用户审批</a></li>
                                <li><a href="userPage">人员管理</a></li>
                                <li><a href="userCenterPage">个人中心</a></li>
                            </ul>
                        </div>
                    </nav>
                </div>
            </div>
        </div>
    </header>
    <section class="donation-section">
        <label class="donation-form-outer" style="width: 100%">
                <br>
                <label class="form-portlet" style="width: 100%">
                    <h4>植物农药管理</h4>
                    <form action="medicinePage" method="get" style="margin: 0 auto;">
                        <label class="form-portlet" style="width: 100%; margin: 0 auto">
                            <label class="row clearfix" style="width: 100%; margin: 0 auto">
                                <label style="margin-left: 15%">农药名称<span></span></label>
                                <label style="padding-right: 10%">
                                        <select name="medicineId" style="height: 50% ;margin-left: 10px;border-radius: 2px">
                                            <option value="">请选择</option>
                                            <option th:each="medi, iterStat:${res.t.medis.data}" th:value="${medi.id}" th:text="${medi.medicineName}"  th:selected="${res.t.medicineId == medi.id}"></option>
                                        </select>
                                    </label>
                                <label>使用状态<span class="required"></span></label>
                                <label style="padding-right: 10%">
                                        <select name="useStatus" style="height: 50% ;margin-left: 10px;border-radius: 2px">
                                            <option value="">请选择</option>
                                            <option th:each="tcCode, iterStat:${res.t.dic}" th:value="${tcCode.code}" th:text="${tcCode.value}"  th:selected="${res.t.useStatus == tcCode.code}"></option>
                                        </select>
                                    </label>
                                <label style="color: #4cae4c; border-radius: 8px; padding: 0 10px; margin-left: 10%">
                                    <button type="submit" class="theme-btn btn-style-two" style="border-radius: 5px;font-weight:bold; padding-top: 5px; padding-bottom: 5px;">查询</button>
                                </label>
                                <label style="color: #4cae4c; border-radius: 8px; padding: 0 10px">
                                    <a type="submit"  href="editMedicine" class="theme-btn btn-style-two" style="border-radius: 5px; font-weight:bold; padding-top: 5px; padding-bottom: 5px;">新增</a>
                                </label>
                            </label>
                        </label>
                    </form>

                    <br><br><br>
                    <table style="width: 100%; text-align: center">
                        <tr>
                            <th>
                                <div>
                                    <span>农药名称</span>
                                </div>
                            </th>
                            <th>
                                <div>
                                    <span>总量</span>
                                </div>
                            </th>
                            <th>
                                <div>
                                    <span>已用量</span>
                                </div>
                            </th>
                            <th>
                                <div>
                                    <span>可用量</span>
                                </div>
                            </th>
                            <th>
                                <div>
                                    <span>使用状态</span>
                                </div>
                            </th>
                            <th>
                                <div>
                                    <span>操作</span>
                                </div>
                            </th>
                        </tr>
                        <tr th:each="medi, iterStat:${res.t.medis.data}" th:class="'td' + ${iterStat.count % 2}">
                            <td>
                                <div>
                                    <span th:text="${medi.medicineName}"></span>
                                </div>
                            </td>
                            <td>
                                <div>
                                    <span th:text="${medi.stockSize}"></span>
                                </div>
                            </td>
                            <td>
                                <div>
                                    <span th:text="${medi.usedSize}"></span>
                                </div>
                            </td>
                            <td>
                                <div>
                                    <span th:text="${medi.enableSize}"></span>
                                </div>
                            </td>
                            <td>
                                <div>
                                    <span th:text="${medi.useStatus}"></span>
                                </div>
                            </td>
                            <td>
                                <a th:href="'editMedicine?id=' + ${medi.id}">编辑</a>
                                <input type="button" th:onclick="javascript:deleteMedicine([[${medi.id}]], [[${res.t.medis.pageNum}]])" value="删除" />
                            </td>
                        </tr>
                    </table>
                </label>
                <br>
            <div>
                <div class="modal-footer no-margin-top">
                    <ul class="pagination pull-right no-margin">
                        <li>
                            <a th:href="'/medicinePage?pageNum=1' + '&medicineId=' + ${res.t.medicineId == null ? '' : res.t.medicineId} + '&useStatus=' + ${res.t.useStatus == null ? '' : res.t.useStatus}">首页</a>
                        </li>
                        <li>
                            <a th:href="'/medicinePage?pageNum=' + ${res.t.medis.jump(-1)} + '&medicineId=' + ${res.t.medicineId == null ? '' : res.t.medicineId} + '&useStatus=' + ${res.t.useStatus == null ? '' : res.t.useStatus}" th:text="上一页"></a>
                        </li>
                        <li>
                            <a th:href="'/medicinePage?pageNum=' + ${res.t.medis.jump(1)} + '&medicineId=' + ${res.t.medicineId == null ? '' : res.t.medicineId} + '&useStatus=' + ${res.t.useStatus == null ? '' : res.t.useStatus}" th:text="下一页"></a>
                        </li>
                        <li>
                            <a th:href="'/medicinePage?pageNum=' + ${res.t.medis.maxPage} + '&medicineId=' + ${res.t.medicineId == null ? '' : res.t.medicineId} + '&useStatus=' + ${res.t.useStatus == null ? '' : res.t.useStatus}">尾页</a>
                        </li>
                        <li>
                            <span th:text="'当前页：' + ${res.t.medis.pageNum}"></span>
                        </li>
                        <li>
                            <span th:text="'页面大小：' + ${res.t.medis.pageSize} + '条/页'"></span>
                        </li>
                        <li>
                            <span th:text="'总条数：' + ${res.t.medis.size}"></span>
                        </li>
                    </ul>
                </div>
            </div>
        </label>
    </section>
</div>
<div class="scroll-to-top scroll-to-target" data-target=".main-header"><span class="fa fa-long-arrow-up"></span></div>


<!--Donate Popup-->

<!-- /.modal -->

<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.fancybox.pack.js"></script>
<script src="js/jquery.fancybox-media.js"></script>
<script src="js/owl.js"></script>
<script src="js/wow.js"></script>
<script src="js/script.js"></script>
</html>
